	<%@page import="${basepackage}.app.model.*" %>
<#include "/macro.include"/> 
<#assign className = table.className>   
<#assign classNameLower = className?uncap_first>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<script>
$(document).ready(function() {
			<#list table.columns as column>
			<#if column.isSecondSelectionColumn>
			$("#${column.referenceSelectionObjectLower}").change(function(){
				var id = $("#${column.referenceSelectionObjectLower}").val();
				$.ajax({
					type: "POST",
					url: "<@jspEl "ctx"/>/${classNameLower}/get${column.referenceTable}ListBy${column.referenceSelectionObject}",
					data: {
						id: id
					},
					dataType: 'json',
					success: function(data){
 						$("#${column.referenceTableLower}").empty();
 						$("#${column.referenceTableLower}").append('<option value=""><fmt:message key="selection.label.pleaseselectone"/></option');
 						$.each(data,function(index,object){
 							$("#${column.referenceTableLower}").append('<option value="' + object.id + '">' + object.name + '</option');
 						})
					
					}
				})
			});

			</#if>
			</#list>
})
</script>
<%@ include file="base.jsp" %>
<#list table.columns as column>
<#if column.htmlHidden>
<input type="hidden" id="${column.columnNameLower}" name="${column.columnNameLower}" value="<@jspEl classNameLower+"."+column.columnNameLower/>"/>
</#if>
</#list>
<div class="form-group">
<#list table.notHiddenColumns?chunk(2) as row>
	<div class="row">
<#list row as column>	
	
		<div class="col-md-2 col-xs-4">
			<label>
			<#if !column.nullable><span class="required">*</span></#if><fmt:message key="${className}.${column.columnNameLower}.title"/>:
			</label>
		</div>
		
	<#if column.isDateColumn>
		<div class="col-md-3 col-xs-8">
			<div class="row input-group date form_date" data-date-format="dd/mm/yyyy">
				<form:input path="${column.columnNameLower}" id="${column.columnNameLower}" cssClass="form-control {${column.JQueryValidateString }}" readonly="true"/>
				<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
				<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
			</div>	
			<div class="row" id="${column.columnNameLower}Error">
				<label class="error"><form:errors path="${column.columnNameLower}"/></label>
			</div>
		</div>
	<#elseif column.isTimestampColumn>
		<div class="col-md-3 col-xs-8">	
			<div class="row input-group date form_date" data-date-format="dd/mm/yyyy">	
				<form:input path="${column.columnNameLower}" id="${column.columnNameLower}" cssClass="form-control {${column.JQueryValidateString }}" readonly="true"/>
				<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
				<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
			</div>
			<div class="row" id="${column.columnNameLower}Error">
				<label class="error"><form:errors path="${column.columnNameLower}"/></label>
			</div>
		</div>
	<#elseif column.isReferenceColumn>
		<div class="col-md-3 col-xs-8">
			<form:select path="${column.referenceTableLower}.id" cssClass="form-control {${column.JQueryValidateString }}" id="${column.referenceTableLower}">
				<form:option value=""><fmt:message key="selection.label.pleaseselectone"/></form:option>
			<#if !column.isSecondSelectionColumn>
				<form:options items="<@jspEl column.referenceTableLower +"List"/>" itemLabel="${column.referenceDisplayColumn}" itemValue="${column.referenceColumn}"  />
			</#if>
			</form:select>
			<label class="error"><form:errors path="${column.referenceTableLower}.id"/></label>
		</div>
	<#else>
		<div class="col-md-3 col-xs-8">	
			<form:input path="${column.columnNameLower}" id="${column.columnNameLower}" cssClass="{${column.JQueryValidateString }} form-control" maxlength="${column.size}" />
			<label class="error"><form:errors path="${column.columnNameLower}"/></label>
		</div>
	</#if>
		

</#list>
	</div>
</#list>		
</div>

